package de.rwth.validation;

import org.eclipse.emf.common.util.EList;
import org.eclipse.xtext.validation.Check;
import de.rwth.adroidGuiLang.*;

public class AdroidGuiLangJavaValidator extends
		AbstractAdroidGuiLangJavaValidator {

	@Check
	public void checkWindowNameStartsWithCapital(Window window) {
		if (!Character.isUpperCase(window.getWindowtitel().charAt(0))) {
			warning("Windowtitle should start with a capital", AdroidGuiLangPackage.WINDOW);
		}
	}

	@Check
	public void checkCheckboxes(RadioBox box) {
		int count = 0;
		EList<RadioButton> list = box.getRadioButtons();
		for (int i = 0; i < list.size(); i++) {
			if (list.get(i) instanceof CheckedRadioButton) count++;
		}
		if (count != 1)
			error("There must be EXACTLY one CheckedRadioButton!",
					AdroidGuiLangPackage.RADIO_BOX);
	}

}
